package com.tedu.pj.sys.controller;

import com.tedu.pj.common.util.ShiroUtils;
import com.tedu.pj.sys.pojo.SysUser;
import com.tedu.pj.sys.pojo.SysUserMenu;
import com.tedu.pj.sys.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author Song
 * @since 2020/10/15
 */
@RequestMapping("/")
@Controller
public class PagesController {

    @Autowired
    private SysMenuService sysMenuService;

    @GetMapping("doIndexUI")
    public String doIndexUI(Model model) {
        SysUser user = ShiroUtils.getUser();
        model.addAttribute("username", user.getUsername());
        List<SysUserMenu> userMenus = sysMenuService.findUserMenusByUserId(user.getId());
        model.addAttribute("userMenus", userMenus);
        return "starter";
    }

//    @GetMapping("log/log_list")
//    public String doLogUI() {
//        return "sys/log_list";
//    }

    @GetMapping("doPageUI")
    public String doPageUI() {
        return "common/page";
    }

    @RequestMapping("doLoginUI")
    public String doLoginUI() {
        System.out.println("login");
        return "login";
    }

    @GetMapping("{module}/{moduleUI}")
    public String doModuleUI(@PathVariable String moduleUI) {
        return "sys/" + moduleUI;
    }

}
